package Login;

import javax.swing.text.html.HTMLWriter;
import java.util.Scanner;

public class Test {
    Scanner scan = new Scanner(System.in);
    String password;

    public static void main(String[] args) {
        Test test = new Test();
        test.login();
    }

    public void login() {
        while (true) {
            System.out.println("请输入您的账号");
            String userword = scan.next();
            boolean iptUserName = userword.matches("^(?![\\d]+$)(?![a-zA-Z]+$)(?![^\\da-zA-Z]+$).{6,20}$");
            System.out.println(iptUserName);
            System.out.println("请输入您的密码");
            password = scan.next();
            boolean iptPassword = password.matches("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{6,}$");
            if (iptUserName || iptPassword) {
                System.out.println("账号密码合法，请再次确认密码");
                Pwd();
            } else {
                System.out.println("账号或密码不正确");
            }

        }
    }

    public void Pwd() {
        while (true) {
            String pwd = scan.next();
            if (pwd.equals(password)) {
                System.out.println("确认密码成功");
                Ema();
            } else {
                System.out.println("密码输入重复，请重新输入");
            }
        }

    }

    public void Ema() {
        boolean flag=true;
        while (flag) {
            System.out.println("请输入您的邮箱");
            String email = scan.next();
            boolean iptEmail = email.matches("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
            if (iptEmail) {
                System.out.println("恭喜你注册成功");
                flag=false;
            } else {
                System.out.println("邮箱格式不对，请重新输入");
            }
        }
    }
}
